<?php

session_start();	
$album=$_POST['album'];
$cuid = $_SESSION['username'];

$conn = oci_connect("gaurav", "gaurav", "xe"); 

$query = "INSERT INTO Album(AlbumID,AlbumName,CreationDate,IsPublic,Caption,Cuid) VALUES(albumseq.nextval,:album,SysDate,'Yes','Yeah!',:cuid)";


$bindargs = array();
array_push($bindargs, array('CUID', $cuid, -1));
array_push($bindargs, array('ALBUM', $album, -1));


$r = db_execute_statement($conn, $query, $bindargs);

header('Location: /StudentHomePageAlbums.php');

function db_execute_statement($conn, $statement, $bindvars = array())
{
  $stid = oci_parse($conn, $statement);
  if (!$stid) {
    db_error($conn, __FILE__, __LINE__);
  }
    // Bind parameters
  foreach ($bindvars as $b) {
    // create local variable with caller specified bind value 
    $$b[0] = $b[1];
    $r = oci_bind_by_name($stid, ":$b[0]", $$b[0], $b[2]);
    if (!$r) {
      db_error($stid, __FILE__, __LINE__);
    }
  }

  $r = oci_execute($stid);
  if (!$r) {
    db_error($stid, __FILE__, __LINE__);
  }
  return($r);
}
?>